# include <bits/stdc++.h>
# define mike 10000
using namespace std;

int main() { 
# ifndef LOCAL
    freopen("expr2013.in", "r", stdin);
    freopen("expr2013.out", "w", stdout);
# endif
    freopen("in", "r", stdin);
    int ans = 0, k = 1, x = 0;
    char op;
    scanf("%d", &k);
    while(scanf("%c%d", &op, &x) != EOF) { 
        if(op == '*') { 
            k *= x;
        } else { 
            ans += k;
            k = x;
        }
        k %= mike;
        ans %= mike;
    }
    ans += k;
    ans %= mike; 
    printf("%d\n", ans);
}
